import * as React from 'react';
import classNames from 'classnames';

export interface DividerProps {
	type?: 'horizontal' | 'vertical';
	children?: React.ReactNode;
	className?: string;
	dashed?: boolean;
	orientation?: 'left' | 'right' | 'center';
}

const Divider: React.FC<DividerProps> = props => {
	const prefixCls = 'bh-divider';
	const {
		type = 'horizontal',
		children,
		className,
		dashed,
		orientation = 'center',
		...restProps
	} = props;
	const hasChildren = !!children;
	const classString = classNames(
		prefixCls, 
		`${prefixCls}-${type}`,
		className,
		{
			[`${prefixCls}-with-text`]: hasChildren,
			[`${prefixCls}-with-text-${orientation}`]: hasChildren,
			[`${prefixCls}-dashed`]: !!dashed,
		}
	);
	
	return (
		<div {...restProps} className={classString}>
		    {children && <span className={`${prefixCls}-inner-text`}>{children}</span>}
		</div>
	)
};

export default Divider;